<?php
namespace app\activityNew\controller;
use think\admin\Controller;
use think\admin\service\AdminService;
use think\admin\helper\QueryHelper;
use app\activityNew\model\ImsEweiShopAd;
use think\admin\model\SystemAuth;
use think\admin\model\SystemBase;
use think\admin\model\SystemUser;
use think\facade\Request;

class Ad extends Controller
{
    public function index()
    {
		
        /*! 判断当前用户的登录状态 */
        $this->login = AdminService::isLogin();
        $this->type = $this->get['type'] ?? '1';
        /*! 菜单为空且未登录跳转到登录页 */
        if (empty($this->menus) && empty($this->login)) {
            $this->redirect(sysuri('admin/login/index'));
        } else {
			ImsEweiShopAd::mQuery()->layTable(function () {
                $this->title = '广告管理';
            }, function (QueryHelper $query) {
                // 加载对应数据列表
                $query->where(['adtype' => $this->type]);
                $query->where(['delete' => 0]);
                // 数据列表搜索过滤
                $query->like('adname#keywords');
            });

            $this->fetch();
        }
    }

	 protected function _index_page_filter(&$data){
		//echo 1111;
	 }

    /**
     * 添加
     * @auth true
     */
    public function add()
    {
        
        ImsEweiShopAd::mForm('form');
    }

    /**
     * 编辑
     * @auth true
     */
    public function edit()
    {
        ImsEweiShopAd::mForm('form');
    }

    /**
     * 删除
     * @auth true
     */
    public function remove()
    {
        ImsEweiShopAd::mDelete();
    }

    /**
     * 修改状态
     * @auth true
     */
    public function status()
    {
        ImsEweiShopAd::mSave($this->_vali([
            'status.in:0,1,2'  => '状态值范围异常！',
            'status.require' => '状态值不能为空！',
        ]));
    }
}
